<template>
  <view class="content">
    <scroll-list ref="scrollList" :scrollFlag="false" @getData="getData">
      <template v-slot="{ item }">
        <view class="item">
          <text>{{ item.sendTimeShow }}</text>
          <uni-rate allow-half :value="item.starsNum" :readonly="true" />
          <view class="right" v-if="item.isGiveScore">{{ item.starsNum*item.eachStarsScore }}分</view>
          <view class="right active" v-else @click="goEvaluate(item)">去评分</view>
        </view>
      </template>
    </scroll-list>
  </view>
</template>

<script>
import scrollList from "@/components/scroll-list/scroll-list.vue";

export default {
  components: { scrollList },
  data() {
    return {
      doctorId:'',
      patientId: uni.getStorageSync("patientId"),
    };
  },
  onShareAppMessage() {
    return this.$util.returnShareObj();
  },
  onLoad(options) {
    this.doctorId=options.doctorId
    this.$nextTick(() => {
      this.$refs.scrollList.getData(1);
    });
  },
  onPullDownRefresh() {
    this.$refs.scrollList.getData(2);
  },
  onReachBottom() {
    this.$refs.scrollList.getData(3);
  },
  methods: {
     refreshByBack(){
            this.$refs.scrollList.getData(2);
    },
    goEvaluate(item) {
      this.$util.goUrl("/pagesPatient/evaluate/index?evId="+item.evId);
    },
    getData(param) {
      this.$api.doctorEvaluateList({pageSize:20,pageNum:param.pageNo,patientId:this.patientId,doctorId:this.doctorId }).then((res) => {
        if (res.code == 200) {
 let list=res.rows.map(item=>{
              if(new Date().getFullYear()==new Date(item.sendTime.replace(/-/g, "/")).getFullYear()){
item.sendTimeShow=item.sendTime.substring(5,10)

              }else{
item.sendTimeShow=item.sendTime.substring(0,10)
              }
              
              return item
            })
        this.$refs.scrollList.setData(list, param.pageNo *20>=res.total);
          
        
        }else{
        this.$refs.scrollList.setData(false,false);

        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.content {
  background: $back-grey-color;
  min-height: 100vh;
}
.item {
  width: 100vw;
  box-sizing: border-box;
  background: #fff;
  border-bottom: 1rpx solid $default-border-color;
  display: flex;
  padding: 30rpx 40rpx;
  justify-content: space-between;
  .right {
    width: 130rpx;
    text-align: right;
  }
  .active {
    color: #4ab6f6;
  }
}
.item::after {
  content: "";
  position: absolute;
  height: 1rpx;
  width: 40rpx;
  background: #fff;
  left: 0;
  bottom: 0;
}
</style>
